package org.fdy.common.core.exception;

import lombok.Data;
import lombok.Getter;
import org.fdy.common.core.enums.ResultCode;

import java.io.Serializable;

/**
 * <p>说明：基础异常</P>
 *
 * @author: fangdayang
 * @create: 2023-10-19 23:57
 **/
@Getter
public class BaseException extends RuntimeException implements Serializable {
    private final Integer code;

    public BaseException(Integer code) {
        super();
        this.code = code;
    }

    public BaseException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BaseException(ResultCode apiCode) {
        super(apiCode.getMessage());
        this.code = apiCode.getCode();
    }

    public BaseException(Throwable cause) {
        super(cause);
        code = ResultCode.FAIL.getCode();
    }
}
